-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: separate out language logic from moduleconfig #3016
Conversation
} | ||
go func() { | ||
// Loading a plugin can be expensive. Is there a better way? | ||
plugin, err := languageplugin.New(ctx, m.Language) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change will eventually (once language plugins operate over gRPC) lead to a slowdown in this logic because now we need to create a language plugin per module just so we can figure out where the schema is saved.
I'm not sure of a good solution to this, other than having a central place FTL saves schemas (similar to the central /.ftl/
external modules) so that having a ModuleConfig is not readed to read the saved schema for a module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not specifically about the slowdown, but the schema won't be saved right? It will be returned over gRPC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plugins don't save the schema, it gets sent over gRPC. What is unresolved at the moment though is how FTL deals with the schema after that. This admin logic is something that breaks if the schema doesn't get saved at all. For now FTL itself is saving the schema just so this and the current deploy logic works and I'll be coming back to this admin stuff a bit later. I've added a section on deployment to the things to do in this main issue here: #2452
|
||
// UpdateDependencies finds the dependencies for a module and returns a | ||
// Module with those dependencies populated. | ||
func UpdateDependencies(ctx context.Context, module Module, plugin LanguagePlugin) (Module, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was unused after previous language plugin changes
"github.com/alecthomas/assert/v2" | ||
) | ||
|
||
func TestExtractModuleDepsGo(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these have been moved to unit tests within languageplugin
"golang.org/x/mod/modfile" | ||
) | ||
|
||
func replacementWatches(moduleDir, deployDir string) ([]string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all this code was previously in moduleconfig
but is all specific to the go plugin
GeneratedSchemaDir: "src/main/ftl-module-schema", | ||
Deploy: []string{"launch", "quarkus-app"}, | ||
// Watch defaults to files related to maven and gradle | ||
Watch: []string{"pom.xml", "src/**", "build/generated", "target/generated-sources"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously watch
was different based on maven/gradle, but I think it's fine to just use the same watch patterns for both
@@ -13,8 +13,8 @@ import ( | |||
|
|||
// DiscoverModules recursively loads all modules under the given directories | |||
// (or if none provided, the current working directory is used). | |||
func DiscoverModules(ctx context.Context, moduleDirs []string) ([]moduleconfig.ModuleConfig, error) { | |||
out := []moduleconfig.ModuleConfig{} | |||
func DiscoverModules(ctx context.Context, moduleDirs []string) ([]moduleconfig.UnvalidatedModuleConfig, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Discover handles UnvalidatedModuleConfig
s now, instead of ModuleConfig
s
@@ -14,162 +14,31 @@ func TestDiscoverModules(t *testing.T) { | |||
ctx := log.ContextWithNewDefaultLogger(context.Background()) | |||
modules, err := DiscoverModules(ctx, []string{"testdata"}) | |||
assert.NoError(t, err) | |||
expected := []moduleconfig.ModuleConfig{ | |||
expected := []moduleconfig.UnvalidatedModuleConfig{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously this test was testing discovery and defaulting.
Now it just tests discovery. Generic defaulting tests can now be found in moduleconfig
tests, while language specific default testing can be found in languageplugin
75c8e11
to
1de7d64
Compare
1f5df72
to
b7fbd5f
Compare
a57e9ce
to
c56ce91
Compare
Why
Language support was previously tightly integrated with how a
ModuleConfig
is created. Without this defaulting, FTL does not know key info about a module like deploy directory or where to find the schema.Another complication is that module defaults for jvm modules is done by looking for certain files to automatically choose defaults for gradle or maven, so we can't get the defaults once per language and use them for all modules of that language.
Creating a ModuleConfig
To create a
ModuleConfig
, the steps are:Other changes
ModuleGoConfig
,ModuleKotlinConfig
,ModuleJavaConfig
, replace withLanguageConfig: map[string]any
map[string]any
and then parse that into anUnvalidatedModuleConfig
usingmapstructure
and then pull out the language config from the correct key (go
,java
,kotlin
, etc)buildengine
caches the defaults per module so that each time it reads the toml it does not to ask for CustomDefaults from the plugin.